﻿
// MFCTest2View.h: CMFCTest2View 类的接口
//

#pragma once

typedef enum class DRAW_TYPE
{
	DT_LINE,
	DT_RECT,
	DT_ELLIPSE,
	DT_PEN,
	DT_CIRCLE
} DRAW_T;

class CMFCTest2View : public CView
{
protected: // 仅从序列化创建
	CMFCTest2View() noexcept;
	DECLARE_DYNCREATE(CMFCTest2View)

// 特性
public:
	CMFCTest2Doc* GetDocument() const;

// 操作
public:

// 重写
public:
	virtual void OnDraw(CDC* pDC);  // 重写以绘制该视图
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:

// 实现
public:
	virtual ~CMFCTest2View();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// 生成的消息映射函数
protected:
	afx_msg void OnFilePrintPreview();
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
private:
	CPoint m_pOrigin;
	CPoint m_rcLastLine;
	bool m_bDraw;
	CRect m_rcLastEllipse;
	DRAW_T m_drawDt;
	CBitmap m_memBitmap;
	CDC m_memDC;
public:
	void DrawLineRealTime(CPoint point);
	void DrawPenRealTime(CPoint point);
	void DrawEllipseRealTime(CPoint point);
	void DrawRectRealTime(CPoint point);
	void DrawCircleRealTime(CPoint point);
	void CMFCTest2View::InitMemDC(int width, int height);
	CDC* GetMemDC();
	CBitmap* GetMemBitMap();
	void SetMemDC();
	afx_msg void OnDrawLine();
	afx_msg void OnDrawEllipse();
	afx_msg void OnDrawPen();
	afx_msg void OnDrawRect();
	virtual void OnInitialUpdate();
	afx_msg void OnDrawCircle();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnUpdateDrawCircle(CCmdUI* pCmdUI);
	afx_msg void OnUpdateDrawEllipse(CCmdUI* pCmdUI);
	afx_msg void OnUpdateDrawLine(CCmdUI* pCmdUI);
	afx_msg void OnUpdateDrawPen(CCmdUI* pCmdUI);
	afx_msg void OnUpdateDrawRect(CCmdUI* pCmdUI);
	afx_msg void OnFileOption();
	void SetDrawColor(COLORREF color);
private:
	UINT m_nLineWidth;
	int m_nLineStyle;
	COLORREF m_color;
	COLORREF m_tempColor;
};

#ifndef _DEBUG  // MFCTest2View.cpp 中的调试版本
inline CMFCTest2Doc* CMFCTest2View::GetDocument() const
   { return reinterpret_cast<CMFCTest2Doc*>(m_pDocument); }
#endif

